import React from 'react';

import { getAuthEmail } from '@/entities/auth/model/selectors';
import { innerUrls } from '@/shared/constants';
import BookOpenImage from '@/shared/icons/emoji/BookWithStar.png';
import { useAppSelector } from '@/shared/store';
import { Button, ButtonVariants } from '@/shared/ui';
import Image from 'next/image';
import { useWindowSize } from 'usehooks-ts';

import cs from './NoFiles.module.scss';

export const NoFiles = ({
  courseId,
  orderEmail,
  isRating,
  status,
}: {
  courseId: number;
  orderEmail?: string;
  isRating?: boolean;
  status?: number;
}) => {
  const email = useAppSelector(getAuthEmail);

  const { width } = useWindowSize();
  return (
    <>
      <div className={cs.block}>
        <Image
          alt="icon"
          height={width > 768 ? 190 : 128}
          quality={100}
          src={BookOpenImage}
          width={width > 768 ? 190 : 128}
        />

        <span className={cs.text}>
          {status === 2
            ? `Отправили информацию на почту ${orderEmail || email}. Проверьте Входящие или Спам.`
            : 'Заказ неоплачен'}
        </span>
        {!isRating && (
          <Button
            className={cs.btn}
            data-testid="link-create_review"
            href={innerUrls.boughtCourse('review', Number(courseId))}
            link
            variant={ButtonVariants.Blue}
          >
            Оставить отзыв
          </Button>
        )}
      </div>
    </>
  );
};
